;
; ASL.SH Version 1.00 (C)1996 HUDSON SOFT
; HuC6273スプライトライブラリ アセンブラ用ヘッダーファイル(ASL.SH)
;
	ifndef _ASL_SH_
_ASL_SH_	equ	1

;	ASL Address Offset (by Word).
ASL_ADR_HEAD		equ	0
ASL_ADR_CNTL		equ	1
ASL_ADR_DSP_X_POS	equ	2
ASL_ADR_DSP_Y_POS	equ	3
ASL_ADR_DSP_XY_SIZE	equ	4
ASL_ADR_SRC_XY_POS	equ	5
ASL_ADR_Z_VAL		equ	6
ASL_ADR_SRC_XY_SIZE 	equ	7
ASL_ADR_SRC_X_OFF	equ	8
ASL_ADR_SRC_Y_OFF	equ	9
ASL_ADR_SRC_X_SCAN	equ	10
ASL_ADR_SRC_Y_SCAN	equ	11
ASL_ADR_PT_BANK		equ	12
ASL_ADR_PT_OFFSET	equ	13

;	ASL Word 0.

;	Sprite Function Level.
ASL_MSK_FNC_LVL		equ	$e000
ASL_SFT_FNC_LVL		equ	13

ASL_VAL_FNC_NONE	equ	$0000
ASL_VAL_FNC_NORM	equ	$2000
ASL_VAL_FNC_NORM_Z	equ	$4000
ASL_VAL_FNC_ZOOMROT	equ	$6000
ASL_VAL_FNC_TBL		equ	$8000

;	HV Flip Flag.
ASL_MSK_V_FLIP		equ	$0200
ASL_SFT_V_FLIP		equ	9
ASL_VAL_V_FLIP		equ	ASL_MSK_V_FLIP

ASL_MSK_H_FLIP		equ	$0100
ASL_SFT_H_FLIP		equ	8
ASL_VAL_H_FLIP		equ	ASL_MSK_H_FLIP

ASL_MSK_HV_FLIP		equ	( ASL_MSK_V_FLIP | ASL_MSK_H_FLIP )
ASL_SFT_HV_FLIP		equ	ASL_SFT_H_FLIP

ASL_VAL_HV_FLIP_NONE	equ	$0000
ASL_VAL_HV_FLIP_H	equ	ASL_VAL_H_FLIP
ASL_VAL_HV_FLIP_V	equ	ASL_VAL_V_FLIP
ASL_VAL_HV_FLIP_HV	equ	( ASL_VAL_H_FLIP | ASL_VAL_V_FLIP )

;	Sprite Source Bank Select.
ASL_MSK_BANKSEL		equ	$001f
ASL_SFT_BANKSEL		equ	0

ASL_MSK_HEAD		equ	( ASL_MSK_FNC_LVL | ASL_MSK_HV_FLIP | ASL_MSK_BANKSEL )

;	ASL Word 1.

;	Collision Detection Enable.
ASL_MSK_CDEN		equ	$8000
ASL_SFT_CDEN		equ	15
ASL_VAL_CDEN		equ	ASL_MSK_CDEN

;	Pixel Draw Enable. (Ghost)
ASL_MSK_GHST		equ	$4000
ASL_SFT_GHST		equ	14
ASL_VAL_GHST		equ	ASL_MSK_GHST

;	Z Compare Flag.
ASL_MSK_ZCMP		equ	$2000
ASL_SFT_ZCMP		equ	13
ASL_VAL_ZCMP		equ	ASL_MSK_ZCMP

;	Z Write Enable.
ASL_MSK_ZWEN		equ	$1000
ASL_SFT_ZWEN		equ	12
ASL_VAL_ZWEN		equ	ASL_MSK_ZWEN

;	CD Result Index.
ASL_MSK_CDRES_IDX	equ	$0700
ASL_SFT_CDRES_IDX	equ	8

;	Flag Set Bits.
ASL_MSK_FLAG_SET	equ	$00f0
ASL_SFT_FLAG_SET	equ	4

;	Flag Check Mask.
ASL_MSK_FLAG_CHK	equ	$000f
ASL_SFT_FLAG_CHK	equ	0

ASL_MSK_CNTL		equ	( ASL_MSK_CDEN | ASL_MSK_GHST | ASL_MSK_ZCMP | ASL_MSK_ZWEN | ASL_MSK_CDRES_IDX | ASL_MSK_FLAG_SET | ASL_MSK_FLAG_CHK )

;	ASL Word 2. (Disp. X Pos)
ASL_MSK_DSP_X_POS	equ	$03ff
ASL_SFT_DSP_X_POS	equ	0

;	ASL Word 3. (Disp. Y Pos)
ASL_MSK_DSP_Y_POS	equ	$01ff
ASL_SFT_DSP_Y_POS	equ	0

;	ASL Word 4. (Disp. Y/X Size)
ASL_MSK_DSP_Y_SIZE	equ	$ff00
ASL_SFT_DSP_Y_SIZE	equ	8

ASL_MSK_DSP_X_SIZE	equ	$00ff
ASL_SFT_DSP_X_SIZE	equ	0

;	ASL Word 5. (Src. Y/X Pos)
ASL_MSK_SRC_Y_POS	equ	$ff00
ASL_SFT_SRC_Y_POS	equ	$8

ASL_MSK_SRC_X_POS	equ	$00ff
ASL_SFT_SRC_X_POS	equ	0

;	ASL Word 6. (Z Value)
ASL_MSK_Z_VAL		equ	$ffff
ASL_SFT_Z_VAL		equ	0

;	ASL Word 7. (Src. Y/X Size)
ASL_MSK_SRC_Y_SIZE	equ	$ff00
ASL_SFT_SRC_Y_SIZE	equ	8

ASL_MSK_SRC_X_SIZE	equ	$00ff
ASL_SFT_SRC_X_SIZE	equ	0

;	ASL Word 8. (Src. X Offset)
ASL_MSK_SRC_X_OFF	equ	$ffff
ASL_SFT_SRC_X_OFF	equ	0

;	ASL Word 9. (Src. Y Offset)
ASL_MSK_SRC_Y_OFF	equ	$ffff
ASL_SFT_SRC_Y_OFF	equ	0

;	ASL Word 10. (Src. X Scan)
ASL_MSK_SRC_X_SCAN	equ	$ffff
ASL_SFT_SRC_X_SCAN	equ	0

;	ASL Word 11. (Src. Y Scan)
ASL_MSK_SRC_Y_SCAN	equ	$ffff
ASL_SFT_SRC_Y_SCAN	equ	0

;	ASL Word 12. (Parameter Table Bank Select)
ASL_MSK_PT_BANKSEL	equ	$001f
ASL_SFT_PT_BANKSEL	equ	0

;	ASL Word 12. (Parameter Table Offset Address)
ASL_MSK_PT_OFF_ADDR	equ	$ffff
ASL_SFT_PT_OFF_ADDR	equ	0

ASLSct	struct
head		ds	2
cntl		ds	2
dsp_x_pos	ds	2
dsp_y_pos	ds	2
dsp_xy_size	ds	2
src_xy_pos	ds	2
z		ds	2
src_xy_size	ds	2
src_x_off	ds	2
src_y_off	ds	2
src_x_scan	ds	2
src_y_scan	ds	2
pt_bank_sel	ds	2
pt_off_addr	ds	2
reserved1	ds	2
reserved2	ds	2
	ends

ASLPt	struct
x_off		ds	2
y_off		ds	2
x_scan		ds	2
y_scan		ds	2
	ends

ASLSource	struct
bank		ds	2
x_pos		ds	2
y_pos		ds	2
x_size		ds	2
y_size		ds	2
x_hot		ds	2
y_hot		ds	2
	ends

ASLQuadrangleParameter	struct
dstXt		ds	2
dstWt		ds	2
dstXb		ds	2
dstWb		ds	2
dstY		ds	2
dstH		ds	2
ptBank		ds	2
ptOffAddr	ds	2
	ends

	globl	ASLMakeZoomSprite
	globl	ASLMakeRotateSprite
	globl	ASLMakeZoomRotateSprite
	globl	ASLMakeQuadrangleSprite

	globl	ASLSetSpriteTable
	globl	ASLSetParameterTable

	globl	ASLMakeSimpleSprite
	globl	ASLMakeSpriteWithZ
	globl	ASLChangeHVFlip
	globl	ASLChangeZ
	globl	ASLChangeCollisionDetection
	globl	ASLClearCollisionDetectionResult
	globl	ASLSenseCollisionDetectionResult
	globl	ASLSetSpriteWindow
	globl	ASLExecuteSprite
	globl	ASLSync
	globl	ASLWaitForSwap

ASLChangeCD		macro
	jal	ASLChangeCollisionDetection
	endm
ASLClearCDResult	macro
	jal	ASLClearCollisionDetectionResult
	endm
ASLSenseCDResult	macro
	jal	ASLSenseCollisionDetectionResult
	endm

	endif	; !_ASL_SH_
